package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.HfTrans;
import com.sc.nft.mapper.HfTransMapper;
import  com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * 汇付可转金额表(sc_hf_trans)数据DAO
 *
 * @author zxy
 * @since 2023-08-09 14:08:38
 * @description 汇付相关
 */
@Slf4j
@Repository
public class HfTransDao extends ServiceImpl<HfTransMapper, HfTrans> {

    public BigDecimal getSumLastAmount(){
        return baseMapper.getSumLastAmount();
    }

    public HfTrans getFirstOne(){
        LambdaQueryWrapper<HfTrans> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HfTrans::getStatus,true);
        wrapper.gt(HfTrans::getLastTransAmount,0);
        wrapper.orderByAsc(HfTrans::getId);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }
    public HfTrans getByPayOrderId(Long payOrderId){
        LambdaQueryWrapper<HfTrans> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(HfTrans::getPayOrderId,payOrderId);
        return getOne(wrapper);
    }

}